package qq2564874169.tuaotuao.fx.caching;

class AppCacheItem {
    public String key;
    public Object value;
    public Integer absoluteExpiration;
    public Integer slidingExpiration;
    public Long getTime;
    public Long createTime;

    static AppCacheItem convert(CacheItem item) {
        AppCacheItem newitem = new AppCacheItem();
        newitem.key = item.key;
        newitem.value = item.value;
        newitem.absoluteExpiration = item.absoluteExpiration;
        newitem.slidingExpiration = item.slidingExpiration;
        newitem.createTime = System.currentTimeMillis();
        newitem.getTime = System.currentTimeMillis();
        return newitem;
    }

    public boolean isExpire() {
        if (absoluteExpiration != null) {
            if (createTime + absoluteExpiration * 1000 < System.currentTimeMillis()) {
                return true;
            }
        }
        if (slidingExpiration != null) {
            if (getTime + slidingExpiration * 1000 < System.currentTimeMillis()) {
                return true;
            }
        }
        return false;
    }
}
